// internal.h - helper header
// used solely for implementation
#ifndef WGAL_INTERNAL_H
#define WGAL_INTERNAL_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <wgal/common.h>
#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>

#pragma comment (lib, "d3d9.lib")
//#ifdef _DEBUG
//#pragma comment (lib, "d3dx9d.lib")
//#else // _DEBUG
#pragma comment (lib, "d3dx9.lib")
//#endif // !_DEBUG
#pragma comment (lib, "Winmm.lib")
#pragma comment (lib, "dsound.lib")
#pragma comment (lib, "dxguid.lib")

WGALBool wgalGraphicsInit(HWND);
WGALVoid wgalGraphicsDeinit();
WGALVoid OnDeviceLost();
WGALVoid OnDeviceReset();
WGALUInt32 GetResourceId(WGALUInt8 type);
WGALUInt32 AddIdRefCount(WGALUInt32 resId);
WGALUInt32 FreeResourceId(WGALUInt32 resId);
HINSTANCE GetModuleInstanceHandle(WGALUInt32 module);
HICON GetIconLarge(WGALUInt32 icon_id);
HICON GetIconSmall(WGALUInt32 icon_id);

extern HWND hWnd;
extern WGALBool wgal_init;
extern WGALBool gfx_init;
extern LPDIRECT3D9 d3d;
extern LPDIRECT3DDEVICE9 d3ddev;
extern D3DPRESENT_PARAMETERS d3dpp;

#define CHECK_INITIALIZED(x)	if(!(x)) RaiseException(WGAL_NOT_INITIALIZED,0,0,NULL)
#define CHECK_ARGUMENT_NULL(x)	if(!(x)) RaiseException(WGAL_ARGUMENT_NULL,0,0,NULL)
#define CHECK_ARGUMENT_VALID(rule)	if(!(rule)) RaiseException(WGAL_ARGUMENT_INVALID,0,0,NULL)
#define SAFE_RELEASE(x) if(x) (x)->Release()
#define DEGTORAD(deg) ((D3DX_PI / 180.0f) * (deg)) // converts from degrees to radians
#define RADTODEG(rad) ((180.0f / D3DX_PI) * (rad)) // converts from radians to degrees

#endif // !WGAL_INTERNAL_H